package JavaSe;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}11:14
 */
public class JoinTest {
    public static void main(String[] args) {
        Thread t = new Thread(new ThreadImp());
        t.start();
        try {
            t.join(2000);
            if (t.isAlive())
                System.out.println("t has not finished");
            else
                System.out.println("t has finished");
            System.out.println("joinFinish");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    static class ThreadImp implements Runnable{

        @Override
        public void run() {
            System.out.println("Begin Thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("End ThreadImp");
        }
    }
}
